<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            line-height: 200px;
            text-align: center;
            background: #ccc;
            position: absolute;
            left: 0;
            top: 0;
            transform: rotate(0deg)
        }
    </style>
</head>

<body>
    <div class="box">
        文字文字文字文字
    </div>
</body>
<script>
    //clientX   到可视区
    //pageX     到页面
    //offsetX   到物体




    let oBox = document.querySelector('.box');
    let old_ang=0;
    oBox.addEventListener('touchstart', (ev) => {
        ev.preventDefault();
        if (ev.targetTouches.length >= 2) {
            //2个手指    clientX  是屏幕的坐标
            let a = ev.targetTouches[0].clientX - ev.targetTouches[1].clientX
            let b = ev.targetTouches[0].clientY - ev.targetTouches[1].clientY
            //算角度
            let ang = Math.atan2(b, a)*180/Math.PI
            let start_ang=old_ang

            function fnMove(ev) {
                if (ev.targetTouches.length >= 2) {
                    let a = ev.targetTouches[0].clientX - ev.targetTouches[1].clientX
                    let b = ev.targetTouches[0].clientY - ev.targetTouches[1].clientY
                    //算角度
                    let ang2 = Math.atan2(b, a)*180/Math.PI;
                    old_ang = start_ang+ang2-ang
                    oBox.style.transform=`rotate(${old_ang}deg)`
                }
            }
            function fnEnd() {
                oBox.removeEventListener('touchmove', fnMove, false);
                oBox.removeEventListener('touchend', fnEnd, false);
            }
            oBox.addEventListener('touchmove', fnMove, false);
            oBox.addEventListener('touchend', fnEnd, false);
        }

    }, false)
</script>

</html>